package net.lcheng.sellerCenter.controller;

import com.alibaba.fastjson.JSON;
import net.lcheng.model.BaseAreas;
import net.lcheng.service.AreasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by LV on 2016/6/29.
 */
@Controller
public class AreasController {
    @Autowired
    private AreasService areasService;
    /**
     * 异步获取地区列表
     * @param parentCode
     * @return
     */
    @RequestMapping(value = "/areas/getAreasList/{parentCode}",method = RequestMethod.GET)
    @ResponseBody
    public String getAreasList(@PathVariable("parentCode") String parentCode){
        if(parentCode.equals("null")) parentCode="";
        List<BaseAreas> areas=areasService.findAreasListByParentCode(parentCode);
       return JSON.toJSONString(areas);
    }
}
